import '../helper/uidata.dart';

import '../helper/cacheHelper.dart';

import '../helper/dioHelper2.dart';

class JXGZP {
  int ID;
  String Guid;
  String Title;
  String BeginTime;
  String EndTime;
  String ZhaMenYaoQiu;
  String JianZhuWu;
  String FanWei;
  String ZBYName;
  String XieShuiGC;
  String Content;
  String CreateTime;
  String WXDW;
  String Contact;
  String Phone1;
  String Phone2;
  String BMQM;
  String BMTM;
  String BMUserID;
  bool BMIfOK;
  String DCQM;
  String DCTM;
  String DCUserID;
  bool DCIfOK;
  String SDQM;
  String SDTM;
  String SDUserID;
  bool SDIfOK;
  String DCLDQM;
  String DCLDTM;
  String DCLDUserID;
  bool DCLDIfOK;
  String GCBLDQM;
  String GCBLDTM;
  String GCBLDUserID;
  bool GCBLDIfOK;
  String SDLDQM;
  String SDLDTM;
  String SDLDUserID;
  bool SDLDIfOK;
  String HZBXName;
  String HuiZhi;
  String HZTM;
  String HZQM;
  String HZQMTM;
  String HZUserID;
  bool HZIfOK;
  String CanUseTM;
  int State;
  String Remark;

  JXGZP(
      this.ID,
      this.Guid,
      this.Title,
      this.BeginTime,
      this.EndTime,
      this.ZhaMenYaoQiu,
      this.JianZhuWu,
      this.FanWei,
      this.ZBYName,
      this.XieShuiGC,
      this.Content,
      this.CreateTime,
      this.WXDW,
      this.Contact,
      this.Phone1,
      this.Phone2,
      this.BMQM,
      this.BMTM,
      this.BMUserID,
      this.BMIfOK,
      this.DCQM,
      this.DCTM,
      this.DCUserID,
      this.DCIfOK,
      this.SDQM,
      this.SDTM,
      this.SDUserID,
      this.SDIfOK,
      this.DCLDQM,
      this.DCLDTM,
      this.DCLDUserID,
      this.DCLDIfOK,
      this.GCBLDQM,
      this.GCBLDTM,
      this.GCBLDUserID,
      this.GCBLDIfOK,
      this.SDLDQM,
      this.SDLDTM,
      this.SDLDUserID,
      this.SDLDIfOK,
      this.HZBXName,
      this.HuiZhi,
      this.HZTM,
      this.HZQM,
      this.HZQMTM,
      this.HZUserID,
      this.HZIfOK,
      this.CanUseTM,
      this.State,
      this.Remark);
  JXGZP.fromJson(Map<String, dynamic> json)
      : ID = json["ID"],
        Guid = json["Guid"],
        Title = json["Title"],
        BeginTime = json["BeginTime"],
        EndTime = json["EndTime"],
        ZhaMenYaoQiu = json["ZhaMenYaoQiu"],
        JianZhuWu = json["JianZhuWu"],
        FanWei = json["FanWei"],
        ZBYName = json["ZBYName"],
        XieShuiGC = json["XieShuiGC"],
        Content = json["Content"],
        CreateTime = json["CreateTime"],
        WXDW = json["WXDW"],
        Contact = json["Contact"],
        Phone1 = json["Phone1"],
        Phone2 = json["Phone2"],
        BMQM = json["BMQM"],
        BMTM = json["BMTM"],
        BMUserID = json["BMUserID"],
        BMIfOK = json["BMIfOK"],
        DCQM = json["DCQM"],
        DCTM = json["DCTM"],
        DCUserID = json["DCUserID"],
        DCIfOK = json["DCIfOK"],
        SDQM = json["SDQM"],
        SDTM = json["SDTM"],
        SDUserID = json["SDUserID"],
        SDIfOK = json["SDIfOK"],
        DCLDQM = json["DCLDQM"],
        DCLDTM = json["DCLDTM"],
        DCLDUserID = json["DCLDUserID"],
        DCLDIfOK = json["DCLDIfOK"],
        GCBLDQM = json["GCBLDQM"],
        GCBLDTM = json["GCBLDTM"],
        GCBLDUserID = json["GCBLDUserID"],
        GCBLDIfOK = json["GCBLDIfOK"],
        SDLDQM = json["SDLDQM"],
        SDLDTM = json["SDLDTM"],
        SDLDUserID = json["SDLDUserID"],
        SDLDIfOK = json["SDLDIfOK"],
        HZBXName = json["HZBXName"],
        HuiZhi = json["HuiZhi"],
        HZTM = json["HZTM"],
        HZQM = json["HZQM"],
        HZQMTM = json["HZQMTM"],
        HZUserID = json["HZUserID"],
        HZIfOK = json["HZIfOK"],
        CanUseTM = json["CanUseTM"],
        State = json["State"],
        Remark = json["Remark"];
  Map<String, dynamic> toJson() => {
        'ID': ID,
        'Guid': Guid,
        'Title': Title,
        'BeginTime': BeginTime,
        'EndTime': EndTime,
        'ZhaMenYaoQiu': ZhaMenYaoQiu,
        'JianZhuWu': JianZhuWu,
        'FanWei': FanWei,
        'ZBYName': ZBYName,
        'XieShuiGC': XieShuiGC,
        'Content': Content,
        'CreateTime': CreateTime,
        'WXDW': WXDW,
        'Contact': Contact,
        'Phone1': Phone1,
        'Phone2': Phone2,
        'BMQM': BMQM,
        'BMTM': BMTM,
        'BMUserID': BMUserID,
        'BMIfOK': BMIfOK,
        'DCQM': DCQM,
        'DCTM': DCTM,
        'DCUserID': DCUserID,
        'DCIfOK': DCIfOK,
        'SDQM': SDQM,
        'SDTM': SDTM,
        'SDUserID': SDUserID,
        'SDIfOK': SDIfOK,
        'DCLDQM': DCLDQM,
        'DCLDTM': DCLDTM,
        'DCLDUserID': DCLDUserID,
        'DCLDIfOK': DCLDIfOK,
        'GCBLDQM': GCBLDQM,
        'GCBLDTM': GCBLDTM,
        'GCBLDUserID': GCBLDUserID,
        'GCBLDIfOK': GCBLDIfOK,
        'SDLDQM': SDLDQM,
        'SDLDTM': SDLDTM,
        'SDLDUserID': SDLDUserID,
        'SDLDIfOK': SDLDIfOK,
        'HZBXName': HZBXName,
        'HuiZhi': HuiZhi,
        'HZTM': HZTM,
        'HZQM': HZQM,
        'HZQMTM': HZQMTM,
        'HZUserID': HZUserID,
        'HZIfOK': HZIfOK,
        'CanUseTM': CanUseTM,
        'State': State,
        'Remark': Remark,
      };

  static Future<bool> Add(JXGZP x1) async {
    var response = await DioHelper.Post("/JXGZP/Add", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Update(JXGZP x1) async {
    // var response = await DioHelper.Post("/JXGZP/Update", x1.toJson());
    var response =
        await DioHelper.Post2(UIData.apiServer, "/JXGZP/Update", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Delete(JXGZP x1) async {
    var st = x1.toJson();
    var response = await DioHelper.Post("/JXGZP/Delete", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<JXGZP?> Get(String where, dynamic data) async {
    var response = await DioHelper.Post("/JXGZP/GetByWhere", {
      "Where": where,
      "obj": data,
    });

    if (response.statusCode == 200) return new JXGZP.fromJson(response.data);
    return null;
  }

  static Future<JXGZP?> GetByID(int ID) async {
    var response =
        await DioHelper.Get("/JXGZP/GetByID?ID=" + ID.toString(), {});

    if (response.statusCode == 200) return new JXGZP.fromJson(response.data);
    return null;
  }
  static Future<List<JXGZP>> GetList2(int state, int pageIndex, int pageSize) async {
    var response = await DioHelper.Get(
        "/JXGZP/GetList?st=$state&p1=" +
            pageIndex.toString() +
            "&ps=" +
            pageSize.toString(),
        {});

    var list1 = <JXGZP>[];
    if (response.statusCode == 200) {
      //print(response.data);
      if (response.data == null) return list1;
      for (var x in response.data) {
        list1.add(new JXGZP.fromJson(x));
      }
    }
    return list1;
  }
  static Future<List<JXGZP>> GetList(
      String where, dynamic data, int pageIndex, int pageSize) async {
    var response = await DioHelper.Post("/JXGZP/GetListByWhere", {
      "Where": where,
      "obj": data,
      "PageIndex": pageIndex,
      "PageSize": pageSize,
    });
    var list1 = <JXGZP>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new JXGZP.fromJson(x));
      }
    }
    return list1;
  }

  static Future<List<JXGZP>> GetAllList() async {
    var response = await DioHelper.Get("/JXGZP/GetAllList", {});
    var list1 = <JXGZP>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new JXGZP.fromJson(x));
      }
    }
    return list1;
  }

  static Future<String?> SendById(
      String title, String content, String userId) async {
    //return null;

    var u1 = CacheHelper.GetUser(userId);
    var id = u1.JPushID;
    var phone = u1.Phone;
    //phone = "18884230190";
    content="泄洪设施检修工作票"+content;
    var response = await DioHelper.Get2("http://47.95.205.213:22351",
        "/notice2?id=$id&name=$content&phone=$phone", {
      "Where": "",
    });

    if (response.statusCode == 200) return response.data;
    return null;
  }

  static Future<String?> SendById2(
      String title, String content, String userId) async {
    return null;

    var response = await DioHelper.Get(
        "/JPush/SendById?title=$title&content=$content&userId=$userId", {
      "Where": "",
    });

    if (response.statusCode == 200) return response.data;
    return null;
  }

  static Future<String?> FindNewAPP() async {
    var id = UIData.appVersion;

    var response = await DioHelper.Get2(
        "http://47.95.205.213:22350", "/newAPP?id=$id", {});

    if (response.statusCode == 200) return response.data;
    return null;
  }
}
